package com.it.collection_traverse;

import java.util.ArrayList;
import java.util.Collection;

public class Demo2 {
    public static void main(String[] args) {
        Collection<String> c = new ArrayList<>();
        c.add("赵敏");
        c.add("小昭");
        c.add("素素");
        c.add("灭绝师太");
        System.out.println(c); // [赵敏, 小昭, 素素, 灭绝师太]
//                                  ele

        // 使用增强for遍历集合或者数组
        /**
         * for(元素的数据类型 变量名：数组或者集合){}
         */
        for (String ele : c) {
            System.out.println(ele);
        }

        String[] names = {"迪丽热巴", "古力娜扎", "易烊千玺"};
        for (String name : names) {
            System.out.println(name);
        }
    }
}
